import numpy as np

# 航道：限制智能体船路径路径
from ship_envs.core.polygon_model import PolygonModel


class Fairway(object):
    def __init__(self, start, end):
        start = np.array(start)
        end = np.array(end)
        vec = end - start
        v_norm = vec / np.linalg.norm(vec)
        vertical_vector = np.array([v_norm[1], -v_norm[0]])
        width = 0.02
        pts = [
            start + width / 2 * vertical_vector,
            start - width / 2 * vertical_vector,
            start - width / 2 * vertical_vector + vec,
            start + width / 2 * vertical_vector + vec,
        ]
        self.model = PolygonModel(pts)
        self.model.set_color((0.8, 0.8, 0.8))

    def get_model(self):
        return self.model
